<!DOCTYPE html>
<html lang="en">
<head>
    <meta charset="UTF-8">
    <title>Title</title>
</head>
<body>

</body>
<script>
    //当函数嵌套时 内部函数如果使用了外部函数的变量 就会产生闭包
    /*function wrap() {
        var a = "a";
        function inner() {
            console.log(a);
        }
        inner()
    }
    wrap()*/


    var obj = {
        name:"damu",
        marry:function(){
            //this劫持
            var that = this;
            [1,2,3].forEach(function(item){
                console.log(item,that.name)
            })
        }
    }

    obj.marry()
</script>
</html>